package com.study.daily.algozuo.y2021.m10.day1020;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2021/10/20 下午 05:12
 * @version: 1.0
 */
public class Code02_MoreThanLeftest {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 3, 4, 5, 7, 9, 12, 16, 21, 34};
        System.out.println(isExist(arr, 5));
    }

    public static int isExist(int[] arr, int target) {
        int left = 0;
        int right = arr.length - 1;
        int middle = left + ((right - left) >> 1);
        int i = -1;
        while(right >= left){
            if(arr[middle] >= target){
                i = middle;
                right = middle - 1;
            } else {
                left = middle + 1;
            }
            middle = left + ((right - left) >> 1);
        }
        return i;
    }

}
